class Preitem {
  constructor(name, age) {
    this.name = name
    this.age = age
  }
}
class PreQueue {
  constructor() {
    this.items = []
  }
  enqueue(name, age) {
    const item = new Preitem(name, age)
    if (this.items.length === 0) {
      this.items.push(item)
    } else {
      let flag = false
      for (let i = 0; i < this.items.length; ++i) {
        if (item.age <= this.items[i].age) {
          this.items.splice(i, 0, item)
          flag = true
          return
        }
      }
      if (!flag) {
        this.items.push(item)
      }
    }
  }
}
const pq = new PreQueue()
pq.enqueue('张三', 1)
pq.enqueue('李四', 3)
pq.enqueue('王五', 2)

console.log(pq)
